//
//  YXStatusRepostCell.swift
//  微博YX
//
//  Created by apple on 15/11/29.
//  Copyright © 2015年 lyx. All rights reserved.
//

import UIKit

/// 转发微博的cell
class YXStatusRetweetedCell: YXStatusCell {
    //覆盖父类的属性
    // 1.添加 override关键字
    // 2.实现属性监视器
    // 3.先调父类的属性监视器,在调子类的属性监视器
    override var status: YXStatus?{
        didSet{
            let name = status?.retweeted_status?.user?.screen_name ?? "没有名字"
            let retweetedText = status?.retweeted_status?.text ?? "没有内容"
            let text = "@" + name + ":" + retweetedText
            forwardLabel.text = text
        }
    }
    //    覆盖父类的方法
    override func prepareUI() {
        super.prepareUI()
        //        添加子类直接的控件
        //        将控件添加到最底部
        contentView.insertSubview(bkButton, atIndex:0)
        contentView.addSubview(forwardLabel)
        //        设置约束
        //        背景按钮
        bkButton.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: contentLabel, size: nil, offset: CGPoint(x: -8, y: 8))
        //        在底部view的垂直右上
        bkButton.ff_AlignVertical(type: ff_AlignType.TopRight, referView: statusBottonView, size: nil, offset: CGPoint(x: 0, y: 0))
        //        微博内容
        forwardLabel.ff_AlignInner(type: ff_AlignType.TopLeft, referView: bkButton, size: nil, offset: CGPoint(x: 8, y: 8))
        //          宽度
        contentView.addConstraint(NSLayoutConstraint(item: forwardLabel, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: UIScreen.mainScreen().bounds.width - 2 * 8))
        
        //        配图的view
        let cons = pictureView.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: forwardLabel, size: CGSize(width: 290, height: 290), offset: CGPoint(x: 0, y: 8))
        pictureViewWidth = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Width)
        pictureViewHight = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Height)
        //
    }
    
    
    
    
    //    懒加载
    //    背景按钮
    private lazy var bkButton: UIButton = {
        let btn = UIButton()
        btn.backgroundColor = UIColor(white: 0.8, alpha: 1)
        return btn
        }()
    
    //    被转发微博的内容
    private lazy var forwardLabel: UILabel = {
        let label = UILabel(color: UIColor.brownColor(), fonSize: 14)
        label.numberOfLines = 0
        return label
        }()

}
